package com.shangbang.verb.controller.record;

import com.shangbang.verb.core.BaseResponse;
import com.shangbang.verb.service.record.LikeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Api(value = "录音--用户喜好类接口", tags = "录音--用户喜好类", description = "")

@RestController
@RequestMapping(value = "/record/like")
public class LikeController {

    @Autowired
    private LikeService likeService;

    /**
     * 用户添加喜欢接口
     * @param request
     * @param response
     * @param uid
     * @param type
     * @param story_id
     * @return
     */
    @ApiOperation(value = "用户添加喜欢接口",notes = "用户对自己喜欢的作品点赞")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "手机号", required = true, dataType = "int"),
            @ApiImplicitParam(name = "type", value = "昵称", required = true, dataType = "int"),
            @ApiImplicitParam(name = "story_id", value = "0:点赞，1：取消）", required = true, dataType = "int"),
    })
    @RequestMapping(value = "/putLikeInfo", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse putLikeInfo(HttpServletRequest request, HttpServletResponse response,
                                               @RequestParam(required = true) Integer uid,
                                               @RequestParam(required = true) Integer type,
                                               @RequestParam(required = true) Integer story_id) {
            Object result = "";
            Integer code = 0;
            String msg = "成功";
            likeService.putLikeInfo(uid,type,story_id);
            return new BaseResponse(code, msg, result);
    }


    /**
     * 获取我的喜欢列表
     * @param request
     * @param response
     * @param page
     * @param num
     * @param uid
     * @return
     */
    @ApiOperation(value = "获取我的喜欢列表接口",notes = "获取我的喜欢列表")
    @ApiResponses({ @ApiResponse(code = 0, message = "操作成功"),
            @ApiResponse(code = -1, message = "操作失败") })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "分页第几页", required = true, dataType = "int"),
            @ApiImplicitParam(name = "num", value = "每页多少条", required = true, dataType = "int"),
            @ApiImplicitParam(name = "uid", value = "用户主键", required = true, dataType = "int")
    })
    @RequestMapping(value = "/updateUser", method = {RequestMethod.POST, RequestMethod.GET})
    public BaseResponse getCarouselList(HttpServletRequest request, HttpServletResponse response,
                                        @RequestParam(required = true) Integer page,
                                        @RequestParam(required=true) Integer num,
                                        @RequestParam(required = true) Integer uid) {
        Object result = "";
        Integer code = 0;
        String msg = "成功";

        result =  likeService.getLikeList(uid,(page-1)*num,num);


        return new BaseResponse(code, msg, result);

    }


}
